<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <cpn :cmessage="message"></cpn>
    </div>
    <template id="cpn">
        <div>
            <h2>{{cmessage}}</h2>
        </div>
    </template>
    <script src="vue.js"></script>
    <script>
        const app = new Vue({
            el:"#app",
            data:{
                message:"app的消息",
                goods:[
                    {id:100, name:"剃须刀", price:18.8},
                    {id:100, name:"剃须刀", price:18.8},
                    {id:100, name:"剃须刀", price:18.8},
                    {id:100, name:"剃须刀", price:18.8},
                    {id:100, name:"剃须刀", price:18.8},
                ]
            },
            components:{
                cpn: {
                    template:`#cpn`,
                    // 自己的数据存这里
                    data:function(){
                        return {
                        }
                    },
                    // 存储父组件传递过来的数据的
                    //数组写法的
                    // props:["cmessage", "cgoods"]

                    //对象写法的    数据格式进行限制
                    props:{
                        cmessage:{
                            type: String,
                            default:"传来没有",//默认值,
                            required:true//必须传
                        }
                    }
                }
            }
        });
    </script>
</body>
</html>